package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.Information;
import com.pgybook.db.entity.domain.InformationEx;
import com.pgybook.db.entity.domain.InformationWithBLOBs;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface InformationMapper {
    int countByExample(InformationEx example);

    int deleteByExample(InformationEx example);

    @Delete({
            "delete from information",
            "where INFORMATIONID = #{informationid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long informationid);

    @Insert({
            "insert into information (INFOTYPE, CONTENTTYPE, ",
            "TITLE, CRTTIME, ",
            "CRTSTAFFID, UPTSTAFFID, ",
            "UPDTIME, STATUS, ",
            "CONTENT, BINARYCONTENT)",
            "values (#{infotype,jdbcType=INTEGER}, #{contenttype,jdbcType=INTEGER}, ",
            "#{title,jdbcType=VARCHAR}, #{crttime,jdbcType=TIMESTAMP}, ",
            "#{crtstaffid,jdbcType=INTEGER}, #{uptstaffid,jdbcType=INTEGER}, ",
            "#{updtime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ",
            "#{content,jdbcType=LONGVARCHAR}, #{binarycontent,jdbcType=LONGVARBINARY})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "informationid", before = false, resultType = Long.class)
    int insert(InformationWithBLOBs record);

    int insertSelective(InformationWithBLOBs record);

    List<InformationWithBLOBs> selectByExampleWithBLOBs(InformationEx example);

    List<Information> selectByExample(InformationEx example);

    @Select({
            "select",
            "INFORMATIONID, INFOTYPE, CONTENTTYPE, TITLE, CRTTIME, CRTSTAFFID, UPTSTAFFID, ",
            "UPDTIME, STATUS, CONTENT, BINARYCONTENT",
            "from information",
            "where INFORMATIONID = #{informationid,jdbcType=BIGINT}"
    })
    @ResultMap("ResultMapWithBLOBs")
    InformationWithBLOBs selectByPrimaryKey(Long informationid);

    int updateByExampleSelective(@Param("record") InformationWithBLOBs record, @Param("example") InformationEx example);

    int updateByExampleWithBLOBs(@Param("record") InformationWithBLOBs record, @Param("example") InformationEx example);

    int updateByExample(@Param("record") Information record, @Param("example") InformationEx example);

    int updateByPrimaryKeySelective(InformationWithBLOBs record);

    @Update({
            "update information",
            "set INFOTYPE = #{infotype,jdbcType=INTEGER},",
            "CONTENTTYPE = #{contenttype,jdbcType=INTEGER},",
            "TITLE = #{title,jdbcType=VARCHAR},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "CRTSTAFFID = #{crtstaffid,jdbcType=INTEGER},",
            "UPTSTAFFID = #{uptstaffid,jdbcType=INTEGER},",
            "UPDTIME = #{updtime,jdbcType=TIMESTAMP},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "CONTENT = #{content,jdbcType=LONGVARCHAR},",
            "BINARYCONTENT = #{binarycontent,jdbcType=LONGVARBINARY}",
            "where INFORMATIONID = #{informationid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKeyWithBLOBs(InformationWithBLOBs record);

    @Update({
            "update information",
            "set INFOTYPE = #{infotype,jdbcType=INTEGER},",
            "CONTENTTYPE = #{contenttype,jdbcType=INTEGER},",
            "TITLE = #{title,jdbcType=VARCHAR},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "CRTSTAFFID = #{crtstaffid,jdbcType=INTEGER},",
            "UPTSTAFFID = #{uptstaffid,jdbcType=INTEGER},",
            "UPDTIME = #{updtime,jdbcType=TIMESTAMP},",
            "STATUS = #{status,jdbcType=INTEGER}",
            "where INFORMATIONID = #{informationid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Information record);
}
